package cc.eddic.practice.spring.domain;

import cc.eddic.practice.spring.jpa.BaseEntity;
import lombok.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "t_sub_category")
@Builder
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Setter
public class SubCategory extends BaseEntity {

    @Column(length = 50)
    private String name;

    @ToString.Exclude
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id")
    private Category category;

    public SubCategory(String name){ this.name = name; }

}
